<template>
  <div>
    <el-input placeholder="请输入您的任务名称，按回车键确认" v-model="content" @keyup.enter.native="addItem"></el-input>
  </div>
</template>

<script>
export default {

  props: {
  },

  data () {
    return {
      content: ''
    }
  },
  methods: {
    addItem () {
      const content = this.content.trim()
      if (!content) {
        alert('请出入任务名称！')
        return
      }
      // this.addTask(content)
      // 触发自定义事件监听addTask
      this.$emit('addTask', content)
      this.content = ''
    }
  }
}
</script>

<style>
  .el-input{
    margin-top: 5px;
  }
</style>
